<?php

namespace App\Repositories\Transformers;

use App\Models\News;
use League\Fractal\TransformerAbstract;

class NewsTransformer extends TransformerAbstract
{
    public function transform(News $news)
    {
        return [
            'id' => $news->id,
            'title' => $news->title,
            'image' => $news->image,
            'type' => $news->type,
            'content' => html_entity_decode($news->content),
            'created_at' => $news->created_at != null ? $news->created_at->toDateTimeString() : null,
        ];
    }
}
